Skip to content

Add per-workbook RenderContext on ExcelWorkbook#2395

Open
swmal wants to merge 98 commits into
develop9from
feature/VariableFontsV1
Open

Add per-workbook RenderContext on ExcelWorkbook#2395
swmal wants to merge 98 commits into
develop9from
feature/VariableFontsV1

Conversation

@swmal

@swmal swmal commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Replace global font singleton with per-workbook RenderContext

Background

The SVG export pipeline for charts and shapes resolved fonts through the global OpenTypeFonts singleton. This leaked global state into the render stack, prevented per-workbook font configuration, and made test isolation difficult.

Changes

Introduces a per-workbook RenderContext (holding the font engine), owned lazily by ExcelWorkbook and threaded through the render hierarchy — DrawingRenderer, text bodies, paragraph render items, and down to LayoutSystem/TextLayoutEngine. This mirrors the ParsingContext pattern used in formula calculation.

Nodes that have a workbook (e.g. DrawingRenderer, DrawingTextBox) fetch the context from it; nodes that don't receive it via constructor. The chart branch reaches it through ChartDrawingObject.RenderContext.

Public API: Workbook.ConfigureFonts(Action<IEpplusFontConfiguration>) for users (no class/constructor knowledge required); UseFontEngine internal for tests.

Also cleans up FontAvailability: it is now a pure result enum (NotFound, FamilyOnly, Exact), with strictness moved to a separate RequireExactFont flag defaulting to false — rendering trusts the fallback chain and no longer throws on a missing theme font.

TextLayoutEngine now carries an OpenTypeFontEngine directly, removing an abstraction-breaking cast and the last singleton fallback in the layout path.

JanKallman and others added 30 commits June 4, 2026 13:49
JanKallman and others added 27 commits June 22, 2026 14:54
…er stack; split FontAvailability into result enum plus RequireExactFont policy
… the SVG export pipeline for charts and shapes, replacing the global OpenTypeFonts singleton; split FontAvailability into a result enum plus RequireExactFont policy
@swmal swmal added the enhancement New feature or request label Jun 29, 2026
@swmal swmal added this to the EPPlus 9.0 or later milestone Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants